package com.hmkj.core.api.juhe.sdk.kit;

/**
 * 描述: strutil
 * 作者: syx
 * 时间: 2016/12/9 10:57
 */
public class StrUtil {

    public static String convert(String utfString){
        StringBuilder sb = new StringBuilder();
        int i = -1;
        int pos = 0;

        while((i=utfString.indexOf("\\u", pos)) != -1){
            sb.append(utfString.substring(pos, i));
            if(i+5 < utfString.length()){
                pos = i+6;
                sb.append((char)Integer.parseInt(utfString.substring(i+2, i+6), 16));
            }
        }

        return sb.toString();
    }

    public static void main(String args[]){
        StrUtil strUtil = new StrUtil();
        String s = "{\"reason\":\"\\u67e5\\u8be2\\u6210\\u529f\",\"result\":{\"bank\":\"\\u90ae\\u653f\\u50a8\\u84c4\\u94f6\\u884c\",\"type\":\"IC\\u7eff\\u5361\\u901a\",\"nature\":\"\\u501f\\u8bb0\\u5361\",\"kefu\":\"95580\",\"logo\":\"http:\\/\\/apiserver.qiniudn.com\\/youzheng.png\",\"info\":\"\"},\"error_code\":0}";
        System.out.println(strUtil.convert(s));
    }
}
